/**
 * Created by apple on 2017/6/25.
 */
import React,{Component} from 'react';
import {
  View, Text,
  StyleSheet, TouchableOpacity, ScrollView
} from "react-native";
import ViewUtil from '../../util/ViewUtil'
import NavigationBar from "../../common/NaviagtionBar"
import LanguageDao,{FLAG_LANGUAGE} from "../../expand/dao/LanguageDao";
export default class CustomKeyPage extends Component{
  constructor(props){
    super(props);
    this.state= {
      dataArray:[]
    };
    this.languageDao = new LanguageDao(FLAG_LANGUAGE.flag_key)
  }
  componentDidMount(){
    this.loadData()
  }
  loadData(){
    this.languageDao.fetch()
      .then(result =>{
        this.setState({dataArray:result})
      })
      .catch((err)=>{
      console.log(err)
      })
  }
  onSave(){
    console.log(1234);
    this.props.navigator.pop()
  }
  renderView(){
    if(!this.state.dataArray||this.state.dataArray.length===0) return null;
    let length = this.state.dataArray.length;
    let views = [];
    for(let i=0,length=length-2;i<length;i+=2){}
    return <View>
      <Text style={{height:400,width:400}}>
        {JSON.stringify(this.state.dataArray)}
      </Text>
    </View>
  }
  render(){
    let rightButton = <TouchableOpacity>
      <View>
        <Text style={styles.title}>保存</Text>
      </View>
    </TouchableOpacity>
      return (<View style={styles.container}>
        <NavigationBar
          title="自定义标签页面"
          style={{
            backgroundColor:'red'
          }}
          rightButton={rightButton}
          statusBar={{
            backgroundColor:"red"
          }}

          leftButton={ViewUtil.getLeftButton(() =>this.onSave())}
        />

        <ScrollView>
          <Text>333</Text>
          {this.renderView()}
        </ScrollView>
      </View>
    )
  }


}
const styles = StyleSheet.create({
  container:{
    flex:1,
    backgroundColor:"#fff"
  },
  text:{
    fontSize:20
  },
  title:{
    fontSize:20,
    color:"#fff",
    paddingRight:10
  }
})
